<?php

class Rzd_Filter_ConvertToValidTime implements Zend_Filter_Interface {

    protected $_fields;

    public function setFields($fields) {
        $this->_fields = $fields;
    }

    public function getFields() {
        return $this->_fields;
    }

    function __construct($filelds) {
        if(is_array($filelds)) {
            $this->setFields($filelds);
        } else {
            throw new Exception('Fields should be array');
        }
    }

    public function filter($values)
    {
        if(count($values)) {
            $fields = $this->getFields();
            foreach($values['data'] as $key => $value) {
                foreach($fields as $fieldName) {
                    $values['data'][$key][$fieldName] = substr($value[$fieldName], 1);
                }
            }
        }

        return $values;
    }
}
